import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class Test {

    public int number() {
        int length = 0;
            for (int i = 1; i <= 90; i++) {
                if(i % 9 == 0) {
                    length ++;
                }
            }
        for (int i = 91; i <= 100 ; i++) {
            if(i % 9 == 0) {
                length = length + 2;
            }
        }
        return length;
        }

    /*public class CountNine {
        public static void main(String[] args) {
            int count = 0;
            for (int i = 1; i <= 100; i++) {
                int num = i;
                while (num > 0) {
                    if (num % 10 == 9) {
                        count++;
                    }
                    num /= 10;
                }
            }
            System.out.println("数字9出现的次数: " + count);
        }*/



        public int num2(int a , int b) {
            int tem = 0;
            if(a < b){
                int temp = a;
                a = b;
                b = temp;
            }

            while (b != 0) {
                int remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }


        public int num(int a , int b) {
            int tem = 0;
            if(a < b){
                int temp = a;
                a = b;
                b = temp;
            }
            /*if(a == b) {
                return a;
            }*/
            for (int i = 1; i <= b; i++) {
                if(a % i == 0 && b % i == 0) {
                     tem = i;
                }
            }
            return tem;
        }



        //计算分数的值
    public int num3() {
            int sum = 0;
        for (int i = 1; i <= 100; i++) {
            if(i % 2 != 0) {
                sum += i;
            }else{
                sum -= i;
            }
        }
        return sum;
    }


    //水仙花树
    public int[] num4(int n) {
        // 临时数组存储所有水仙花数
        int[] temp = new int[100]; // 最多100个，实际只有4个
        int count = 0; // 记录水仙花数的个数

        for (int i = 100; i < n; i++) {
            int a = i / 100;        // 百位
            int b = (i / 10) % 10;  // 十位
            int c = i % 10;         // 个位

            if ((a*a*a + b*b*b + c*c*c) == i) {
                temp[count++] = i; // 存储水仙花数并增加计数
            }
        }

        // 创建恰好大小的数组
        int[] result = new int[count];
        System.arraycopy(temp, 0, result, 0, count);

        return result;
    }


    public void num5() {
            Scanner scanner = new Scanner(System.in);
            while(scanner.hasNextInt()){
                Random random = new Random(100);
                int a = random.nextInt();
                System.out.println("请输入一个0 - 100之间的数");
                int m = scanner.nextInt();
                if(m > a){
                    System.out.println("大了");
                }else if(m == a){
                    System.out.println("猜对了");
                }else{
                    System.out.println("小了");
                }
            }
    }


    public static void main(String[] args) {
        Test test = new Test();
        int a = test.number();

        //Scanner scanner = new Scanner(System.in);
        //System.out.println("请逐个输入两个数字");
        //int num1 = scanner.nextInt();
        //int num2 = scanner.nextInt();

        //int b = test.num2(num1 , num2);

        int c = test.num3();
        System.out.println(c);

        int[] n = new int[100];
        n = test.num4(999);
        System.out.println(Arrays.toString(n));


        test.num5();

    }








}
